package com.demonzym.framework.activitymanager;

import android.app.ProgressDialog;
import android.os.Bundle;
import android.widget.Toast;

import com.actionbarsherlock.app.SherlockActivity;
import com.demonzym.framework.dialog.MyDialog;
import com.demonzym.myapplication.MyApplication;
import com.demonzym.videoplayer.R;

public class BaseActivity extends SherlockActivity {
	private String TAG;
	
    public static int THEME = R.style.Theme_Sherlock_Light;
    
	private ProgressDialog mWaitingProgress;
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        setTheme(THEME);
    	super.onCreate(savedInstanceState);
    	
    	NormalActivityManager.getInstance().addActivity(this);
    }

	@Override
	protected void onDestroy() {
		NormalActivityManager.getInstance().removeActivity(this);
		super.onDestroy();
		
	}
	
	protected void toastSomething(String str){
		Toast.makeText(this, str, Toast.LENGTH_SHORT).show();
	}
	
	protected void waitingSomething(String message){
		waitingSomething(null, message);
	}
	
	protected void waitingSomething(String title, String message){
		if(mWaitingProgress != null)
			stopWaiting();
		
		mWaitingProgress = MyDialog.showProgressDialog(this, title, message, true, true);
	}
	protected void stopWaiting(){
		if(mWaitingProgress != null){
			mWaitingProgress.dismiss();
			mWaitingProgress = null;
		}
	}
	protected boolean isWaiting(){
		return (mWaitingProgress != null);
	}
		
	public void finishApplication(){
		MyApplication.getAppInstance().finishApp();
	}
	
	public void setTag(String tag){
		TAG = tag;
	}
}
